var sql = require('mysql')
var { createConnection } = sql
var conn = createConnection({
    host: 'localhost',
    port: 3306,
    user: 'root',
    password: 'root',
    database: '2213'
})
// conn.connect();  开启链接
// conn.end();      关闭链接


// 执行sql语句 => 查询
// err    报错
// result 查询结果
// field  字段信息
conn.connect()
conn.query("select id,name,class,chinese,math,english,chinese+math+english as total from grade where class='2205'", function (err, result, field) {
    if (err) {
        throw err;
    } else {
        console.log(result);
        conn.end()
    }
})